package bishizhuanyong.滴滴;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n = scanner.nextInt();
        int[] l=new int[n];
        int[] r=new int[n];
        int[] t=new int[n];
        int min=Integer.MAX_VALUE;
        for (int i=0;i<l.length;i++) {
            l[i] = scanner.nextInt();
            min=Math.min(l[i],min);
        }
        int max=Integer.MIN_VALUE;
        for (int i=0;i<l.length;i++) {
            r[i] = scanner.nextInt();
            max=Math.max(max,r[i]);
        }
        for (int i=0;i<l.length;i++)
            t[i]=scanner.nextInt();

        HashSet<Integer> set=new HashSet<>();
        for (int i=0;i<n;i++){
            int ll=l[i];
            int rr=r[i];
            for (int m=ll;m<=rr;m++)
                set.add(m);
        }
        int[] temp=new int[max-min+1];
        for (int i=0;i<temp.length;i++) {
            if (set.contains(i+min))
                temp[i] = cal(i + min);
        }
        int[] res=new int[n];
        for (int i=0;i<n;i++){
            int count=0;
            for (int p=l[i];p<=r[i];p++){
                if (temp[p-min]==t[i])
                    count++;
            }
            res[i]=count;
            System.out.print(res[i]+" ");
        }

    }

    public static int cal(int num){
        int res=0;
        while (num!=0){
            int tmp=num%10;
            res^=tmp;
            num=num/10;
        }
        return res;
    }
}

/*
public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n = scanner.nextInt();
        int[] l=new int[n];
        int[] r=new int[n];
        int[] t=new int[n];
        int min=Integer.MAX_VALUE;
        for (int i=0;i<l.length;i++) {
            l[i] = scanner.nextInt();
            min=Math.min(l[i],min);
        }
        int max=Integer.MIN_VALUE;
        for (int i=0;i<l.length;i++) {
            r[i] = scanner.nextInt();
            max=Math.max(max,r[i]);
        }
        for (int i=0;i<l.length;i++)
            t[i]=scanner.nextInt();
        int[] temp=new int[max-min+1];
        for (int i=0;i<temp.length;i++)
            temp[i]=cal(i+min);
        int[] res=new int[n];
        for (int i=0;i<n;i++){
            int count=0;
           for (int p=l[i];p<=r[i];p++){
               if (temp[p-min]==t[i])
                   count++;
           }
           res[i]=count;
            System.out.print(res[i]+" ");
        }
    }
 */

/*
Scanner scanner=new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] weights=new int[n];
        long sum=0;
        for (int i=0;i<n;i++) {
            weights[i] = scanner.nextInt();
            sum+= weights[i];
        }
        Arrays.sort(weights);
        long right_sum=0;
        int res=1;
        for (int i= weights.length-1;i>=0;i--){
            long cur=sum-right_sum;
            double averge=(double) cur/(i+1);
            System.out.println(averge);
            if ((double)weights[i]<=averge*k){
                res=i+1;
                break;
            }
            right_sum+=weights[i];
        }
        System.out.println(res);
 */
